/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CadastraCliente.java
 *
 * Created on 29/03/2012, 01:42:26
 */
package tela;

import bd.Consultas;
import java.awt.Color;
import java.awt.Cursor;
import java.sql.SQLException;
import java.util.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.util.JRLoader;
import relatorio.ConectaBanco;
import relatorio.ReportUtils;
import tabela.Analise;
import tabela.Cliente;
import tabela.Funcionario;
import tabela.PedidoServico;
import tabela.ResponsavelTecnico;

/**
 *
 * @author Edu
 */
public class CadastraBuscaPedidoDeServico extends javax.swing.JPanel {

    /**
     * Creates new form CadastraCliente
     */
    private String idPedidoSelecionado = "999999";
    private int idClienteSelecionado = 999999;
    private int ERRO = 0;
    private int SUCESSO = 1;
    private int INFO = 2;

    public CadastraBuscaPedidoDeServico() {
        initComponents();
        preencheCombos();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        buttonGroup1 = new javax.swing.ButtonGroup();
        jTextFieldNomeCliente = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        adicionarRequisito = new javax.swing.JButton();
        especie = new javax.swing.JComboBox();
        precoUnitario = new javax.swing.JFormattedTextField();
        precoTotal = new javax.swing.JFormattedTextField();
        jScrollPane5 = new javax.swing.JScrollPane();
        tabelaRequisitos = new javax.swing.JTable();
        removerRequisitos = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        qtdAmostra = new javax.swing.JFormattedTextField();
        AnalisePz = new javax.swing.JRadioButton();
        AnaliseG = new javax.swing.JRadioButton();
        AnaliseGa = new javax.swing.JRadioButton();
        AnaliseEa = new javax.swing.JRadioButton();
        AnalisePms = new javax.swing.JRadioButton();
        AnaliseTz = new javax.swing.JRadioButton();
        AnaliseOgm = new javax.swing.JRadioButton();
        AnaliseSi = new javax.swing.JRadioButton();
        AnaliseTs = new javax.swing.JRadioButton();
        AnaliseUm = new javax.swing.JRadioButton();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        jLabel31 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        jLabel33 = new javax.swing.JLabel();
        lote = new javax.swing.JTextField();
        cultivar = new javax.swing.JTextField();
        peneira = new javax.swing.JTextField();
        classe = new javax.swing.JTextField();
        sckg = new javax.swing.JTextField();
        safra = new javax.swing.JTextField();
        categoria = new javax.swing.JTextField();
        basir = new javax.swing.JTextField();
        observacao = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jFormattedTextFieldDataAmostragem = new javax.swing.JFormattedTextField();
        jLabel36 = new javax.swing.JLabel();
        pesoAmostraSub = new javax.swing.JTextField();
        jFormattedTextFieldDataRecebimento = new javax.swing.JFormattedTextField();
        jLabel37 = new javax.swing.JLabel();
        jLabel38 = new javax.swing.JLabel();
        tratada = new javax.swing.JComboBox();
        jPanel2 = new javax.swing.JPanel();
        jLabel25 = new javax.swing.JLabel();
        jTextFieldBuscaCliente = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        jListClientes = new javax.swing.JList();
        jPanel5 = new javax.swing.JPanel();
        jTextFieldRazaoSocial = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jRadioButtonPessoaFisica = new javax.swing.JRadioButton();
        jRadioButtonPessoaJuridica = new javax.swing.JRadioButton();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jFormattedTextFieldCpf = new javax.swing.JFormattedTextField();
        jFormattedTextFieldRG = new javax.swing.JFormattedTextField();
        jFormattedTextFieldCnpj = new javax.swing.JFormattedTextField();
        jFormattedTextFieldInscricaoEstadual = new javax.swing.JFormattedTextField();
        jFormattedTextFieldRenasem = new javax.swing.JFormattedTextField();
        jLabel27 = new javax.swing.JLabel();
        jTextFieldNome = new javax.swing.JTextField();
        jScrollPane6 = new javax.swing.JScrollPane();
        mensagens = new javax.swing.JTextArea();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane7 = new javax.swing.JScrollPane();
        jListPedidos = new javax.swing.JList();
        jButtonVisualizaPedido = new javax.swing.JButton();
        jButtonSalvaPedido = new javax.swing.JButton();
        jButtonExcluiPedido = new javax.swing.JButton();
        NovoPedido = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        precoTotalTudo = new javax.swing.JTextField();
        jLabel34 = new javax.swing.JLabel();
        recebidopor = new javax.swing.JFormattedTextField();
        jLabel2 = new javax.swing.JLabel();
        jFormattedTextFieldDataPedido = new javax.swing.JFormattedTextField();
        jLabel13 = new javax.swing.JLabel();
        jComboBoxRespTec = new javax.swing.JComboBox();
        NumPedido = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jButtonFichaAnalise = new javax.swing.JButton();
        jButtonFichaSanidade = new javax.swing.JButton();
        jComboBoxTipo = new javax.swing.JComboBox();
        jPanel8 = new javax.swing.JPanel();
        jLabel35 = new javax.swing.JLabel();
        jFormattedTextFieldAnolivro = new javax.swing.JFormattedTextField();
        jButtonImprimePedido1 = new javax.swing.JButton();
        jPanel9 = new javax.swing.JPanel();
        jButtonImprimePedido = new javax.swing.JButton();
        jButtonImprimePedido2 = new javax.swing.JButton();
        jButtonEtiqueta = new javax.swing.JButton();
        jPanel10 = new javax.swing.JPanel();
        jButtonImprimePesoMil = new javax.swing.JButton();

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(jTable1);

        jTextFieldNomeCliente.setEditable(false);

        setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        jLabel6.setBackground(new java.awt.Color(255, 255, 255));
        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel6.setText("Pedido de Serviço");

        jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/figura/seta.png"))); // NOI18N
        jLabel7.setMinimumSize(new java.awt.Dimension(10, 256));

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 2, true), "Análises", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 3, 14), java.awt.Color.gray)); // NOI18N

        jLabel3.setText("Quantidade:");

        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel4.setText("Espécie:");

        jLabel5.setText("Descrição dos Serviços (Análise):");

        jLabel8.setText("Preço Unitário:");

        jLabel9.setText("Preço Total:");

        adicionarRequisito.setText("Adicionar Análise");
        adicionarRequisito.setEnabled(false);
        adicionarRequisito.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                adicionarRequisitoActionPerformed(evt);
            }
        });

        especie.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Milho", "Soja", "Feijao", "Trigo", "Triticale", "Aveia Branca", "Aveia Preta", "Azevem", "Canola", "Cevada", "Fumo", "Arroz" }));
        especie.setEnabled(false);

        precoUnitario.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0.00"))));
        precoUnitario.setToolTipText("");
        precoUnitario.setEnabled(false);
        precoUnitario.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                precoUnitarioKeyReleased(evt);
            }
        });

        precoTotal.setEditable(false);
        precoTotal.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        precoTotal.setToolTipText("");
        precoTotal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                precoTotalActionPerformed(evt);
            }
        });

        tabelaRequisitos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Nº da Amostra", "Nº Lote", "Descrição", "Especie", "Peneira", "Cultivar", "Nº Sc/Kg", "Classe", "Safra", "Categoria", "Obs", "BAS/I.R.", "Qde Amostra", "Preço Unitário (R$)", "Preço Total (R$)", "Recebimento Amostra", "Data Amostragem", "Peso Amostra", "Tratada"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tabelaRequisitos.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jScrollPane5.setViewportView(tabelaRequisitos);
        tabelaRequisitos.getColumnModel().getColumn(0).setPreferredWidth(120);
        tabelaRequisitos.getColumnModel().getColumn(2).setPreferredWidth(200);

        removerRequisitos.setText("Remover Análise");
        removerRequisitos.setEnabled(false);
        removerRequisitos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removerRequisitosActionPerformed(evt);
            }
        });

        jLabel11.setText("R$");

        jLabel17.setText("R$");

        qtdAmostra.setEditable(false);
        qtdAmostra.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));
        qtdAmostra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                qtdAmostraActionPerformed(evt);
            }
        });

        AnalisePz.setText("PZ");
        AnalisePz.setEnabled(false);

        AnaliseG.setText("G");
        AnaliseG.setEnabled(false);

        AnaliseGa.setText("G.A.");
        AnaliseGa.setEnabled(false);

        AnaliseEa.setText("E.A.");
        AnaliseEa.setEnabled(false);

        AnalisePms.setText("PMS");
        AnalisePms.setEnabled(false);

        AnaliseTz.setText("TZ");
        AnaliseTz.setEnabled(false);

        AnaliseOgm.setText("OGM");
        AnaliseOgm.setEnabled(false);

        AnaliseSi.setText("SI");
        AnaliseSi.setEnabled(false);

        AnaliseTs.setText("TS");
        AnaliseTs.setEnabled(false);

        AnaliseUm.setText("UM");
        AnaliseUm.setEnabled(false);

        jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel14.setText("Lote:");

        jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel15.setText("Peneira:");

        jLabel18.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel18.setText("Cultivar:");

        jLabel28.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel28.setText("Nº Sc/Kg:");

        jLabel29.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel29.setText("Classe:");

        jLabel30.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel30.setText("Safra:");

        jLabel31.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel31.setText("Categoria:");

        jLabel32.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel32.setText("Observação:");

        jLabel33.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel33.setText("BAS/I.R.:");

        lote.setEditable(false);

        cultivar.setEditable(false);

        peneira.setEditable(false);

        classe.setEditable(false);

        sckg.setEditable(false);

        safra.setEditable(false);

        categoria.setEditable(false);

        basir.setEditable(false);

        observacao.setEditable(false);

        jLabel1.setText("Data Amostragem: ");

        try {
            jFormattedTextFieldDataAmostragem.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jFormattedTextFieldDataAmostragem.setEnabled(false);

        jLabel36.setText("Peso amostra submetida:");

        pesoAmostraSub.setEditable(false);

        try {
            jFormattedTextFieldDataRecebimento.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jFormattedTextFieldDataRecebimento.setEnabled(false);

        jLabel37.setText("Data Recebimento:");

        jLabel38.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel38.setText("Tratada:");

        tratada.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Sim", "Não" }));
        tratada.setEnabled(false);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(removerRequisitos, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE)
                            .addComponent(jLabel33, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(lote, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(peneira, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(10, 10, 10)
                                .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cultivar, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel28, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(sckg, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(11, 11, 11)
                                .addComponent(jLabel29)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(classe, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel30)
                                .addGap(8, 8, 8)
                                .addComponent(safra, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel31, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(categoria, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addComponent(qtdAmostra, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(2, 2, 2)
                                        .addComponent(precoUnitario, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel38, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(tratada, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel36))
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addComponent(especie, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel37)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jFormattedTextFieldDataRecebimento, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(AnalisePz)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addComponent(AnaliseG)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(AnaliseGa)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(AnaliseEa)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(AnalisePms)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(AnaliseTz)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(AnaliseOgm)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(AnaliseSi)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(AnaliseTs)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(AnaliseUm, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                                        .addComponent(pesoAmostraSub, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel17)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(precoTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(adicionarRequisito, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(basir, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel32, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(observacao)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jFormattedTextFieldDataAmostragem, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel28, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel29, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel30, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel31, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(cultivar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(classe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(sckg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(peneira, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(safra, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(categoria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lote, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel32, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(observacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel33, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(basir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel1)
                        .addComponent(jFormattedTextFieldDataAmostragem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(AnaliseTz, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(AnalisePz)
                            .addComponent(AnaliseG)
                            .addComponent(AnaliseGa)
                            .addComponent(AnaliseEa)
                            .addComponent(AnalisePms)
                            .addComponent(AnaliseOgm)
                            .addComponent(AnaliseTs)
                            .addComponent(AnaliseUm)
                            .addComponent(AnaliseSi)
                            .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jFormattedTextFieldDataRecebimento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel37)))
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel4)
                        .addComponent(especie, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(qtdAmostra, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(precoUnitario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11)
                    .addComponent(precoTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17)
                    .addComponent(jLabel9)
                    .addComponent(adicionarRequisito)
                    .addComponent(jLabel36)
                    .addComponent(pesoAmostraSub, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel38, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tratada, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(removerRequisitos)
                .addGap(5, 5, 5))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 2, true), "Buscar Cliente", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 3, 14), java.awt.Color.gray)); // NOI18N

        jLabel25.setText("Nome/Razão Social");

        jButton2.setText("Buscar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jListClientes.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jListClientesValueChanged(evt);
            }
        });
        jScrollPane3.setViewportView(jListClientes);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel25)
                        .addGap(0, 110, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jTextFieldBuscaCliente)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton2)))
                        .addContainerGap())))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel25)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldBuscaCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 2, true), "Dados do Cliente", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 3, 14), java.awt.Color.gray)); // NOI18N

        jTextFieldRazaoSocial.setEditable(false);
        jTextFieldRazaoSocial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldRazaoSocialActionPerformed(evt);
            }
        });

        jLabel20.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel20.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel20.setText("CNPJ:");

        jLabel16.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel16.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel16.setText("Razão Social:");

        jRadioButtonPessoaFisica.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jRadioButtonPessoaFisica.setText("Física");
        jRadioButtonPessoaFisica.setEnabled(false);

        jRadioButtonPessoaJuridica.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jRadioButtonPessoaJuridica.setText("Jurídica");
        jRadioButtonPessoaJuridica.setEnabled(false);

        jLabel21.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel21.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel21.setText("Pessoa:");

        jLabel22.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel22.setText("Inscrição Estadual:");

        jLabel24.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel24.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel24.setText("Nome:");

        jLabel23.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel23.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel23.setText("CPF:");

        jLabel26.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel26.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel26.setText("R.G:");

        jFormattedTextFieldCpf.setEditable(false);
        try {
            jFormattedTextFieldCpf.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("###.###.###-##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jFormattedTextFieldCpf.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jFormattedTextFieldCpfActionPerformed(evt);
            }
        });

        jFormattedTextFieldRG.setEditable(false);
        try {
            jFormattedTextFieldRG.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##.###.###-#")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        jFormattedTextFieldCnpj.setEditable(false);
        try {
            jFormattedTextFieldCnpj.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##.###.###/####-##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        jFormattedTextFieldInscricaoEstadual.setEditable(false);
        try {
            jFormattedTextFieldInscricaoEstadual.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("###.###.###.###")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        jFormattedTextFieldRenasem.setEditable(false);
        try {
            jFormattedTextFieldRenasem.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("UU-#####/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        jLabel27.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel27.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel27.setText("RENASEM:");

        jTextFieldNome.setEditable(false);
        jTextFieldNome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldNomeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jRadioButtonPessoaFisica, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jRadioButtonPessoaJuridica)
                        .addGap(23, 23, 23)
                        .addComponent(jLabel27, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jFormattedTextFieldRenasem, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jLabel23, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel20, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel16, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE))
                            .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldNome, javax.swing.GroupLayout.PREFERRED_SIZE, 404, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                                    .addComponent(jFormattedTextFieldCpf, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jLabel26, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jFormattedTextFieldRG))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                                    .addComponent(jFormattedTextFieldCnpj, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jLabel22)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jFormattedTextFieldInscricaoEstadual))
                                .addComponent(jTextFieldRazaoSocial, javax.swing.GroupLayout.PREFERRED_SIZE, 404, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioButtonPessoaFisica)
                    .addComponent(jRadioButtonPessoaJuridica)
                    .addComponent(jLabel21)
                    .addComponent(jFormattedTextFieldRenasem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel27))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel24)
                    .addComponent(jTextFieldNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel23)
                    .addComponent(jLabel26)
                    .addComponent(jFormattedTextFieldCpf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jFormattedTextFieldRG, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(jLabel22)
                    .addComponent(jFormattedTextFieldCnpj, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jFormattedTextFieldInscricaoEstadual, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(jTextFieldRazaoSocial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        mensagens.setBackground(new java.awt.Color(204, 204, 204));
        mensagens.setColumns(20);
        mensagens.setEditable(false);
        mensagens.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        mensagens.setForeground(new java.awt.Color(204, 0, 0));
        mensagens.setRows(1);
        mensagens.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        jScrollPane6.setViewportView(mensagens);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 2, true), "Pedidos do Cliente", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 3, 14), java.awt.Color.gray)); // NOI18N

        jListPedidos.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jListPedidosValueChanged(evt);
            }
        });
        jScrollPane7.setViewportView(jListPedidos);

        jButtonVisualizaPedido.setText("Visualizar/Alterar Pedido");
        jButtonVisualizaPedido.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonVisualizaPedidoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addComponent(jButtonVisualizaPedido, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(34, 34, 34))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonVisualizaPedido)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButtonSalvaPedido.setText("Salvar Pedido ");
        jButtonSalvaPedido.setEnabled(false);
        jButtonSalvaPedido.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSalvaPedidoActionPerformed(evt);
            }
        });

        jButtonExcluiPedido.setText("Excluir Pedido");
        jButtonExcluiPedido.setEnabled(false);
        jButtonExcluiPedido.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonExcluiPedidoActionPerformed(evt);
            }
        });

        NovoPedido.setText("Novo Pedido");
        NovoPedido.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NovoPedidoActionPerformed(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel10.setText("PREÇO TOTAL");

        jLabel19.setText("R$");

        precoTotalTudo.setEditable(false);
        precoTotalTudo.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N

        jLabel34.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel34.setText("Recebido por:");

        recebidopor.setEditable(false);
        recebidopor.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));
        recebidopor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                recebidoporActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel2.setText("Data: ");

        try {
            jFormattedTextFieldDataPedido.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jFormattedTextFieldDataPedido.setEnabled(false);

        jLabel13.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel13.setText("Responsável Técnico");

        jComboBoxRespTec.setEnabled(false);

        NumPedido.setEditable(false);
        NumPedido.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        NumPedido.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NumPedidoActionPerformed(evt);
            }
        });

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel12.setText("Pedido");

        jPanel6.setBackground(new java.awt.Color(255, 255, 255));
        jPanel6.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204), 4));

        jPanel7.setBackground(new java.awt.Color(255, 255, 255));
        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Fichas de Análise", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, new java.awt.Color(0, 0, 0)));

        jButtonFichaAnalise.setText("Ficha de Análise");
        jButtonFichaAnalise.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonFichaAnaliseActionPerformed(evt);
            }
        });

        jButtonFichaSanidade.setText("Ficha Sanidade");
        jButtonFichaSanidade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonFichaSanidadeActionPerformed(evt);
            }
        });

        jComboBoxTipo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Definitiva", "Previa" }));

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addComponent(jButtonFichaAnalise)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButtonFichaSanidade)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBoxTipo, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(66, 66, 66))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jButtonFichaAnalise)
                .addComponent(jComboBoxTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jButtonFichaSanidade))
        );

        jPanel8.setBackground(new java.awt.Color(255, 255, 255));
        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Livro de Protocolo", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, new java.awt.Color(0, 0, 0)));

        jLabel35.setText("Ano:");

        try {
            jFormattedTextFieldAnolivro.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        jButtonImprimePedido1.setText("Livro de Protocolo");
        jButtonImprimePedido1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonImprimePedido1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap(42, Short.MAX_VALUE)
                .addComponent(jButtonImprimePedido1, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel35)
                .addGap(2, 2, 2)
                .addComponent(jFormattedTextFieldAnolivro, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel35)
                .addComponent(jFormattedTextFieldAnolivro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addComponent(jButtonImprimePedido1)
        );

        jPanel9.setBackground(new java.awt.Color(255, 255, 255));
        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Impressão", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, new java.awt.Color(0, 0, 0)));

        jButtonImprimePedido.setText("Pedido de Serviço");
        jButtonImprimePedido.setEnabled(false);
        jButtonImprimePedido.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonImprimePedidoActionPerformed(evt);
            }
        });

        jButtonImprimePedido2.setText("Termo de Recebimento");
        jButtonImprimePedido2.setEnabled(false);
        jButtonImprimePedido2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonImprimePedido2ActionPerformed(evt);
            }
        });

        jButtonEtiqueta.setText("Etiqueta");
        jButtonEtiqueta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonEtiquetaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addComponent(jButtonImprimePedido)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonImprimePedido2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButtonEtiqueta))
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonImprimePedido)
                    .addComponent(jButtonImprimePedido2)
                    .addComponent(jButtonEtiqueta))
                .addGap(0, 0, Short.MAX_VALUE))
        );

        jPanel10.setBackground(new java.awt.Color(255, 255, 255));
        jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Peso de Mil Sementes ", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, new java.awt.Color(0, 0, 0)));

        jButtonImprimePesoMil.setText("Peso Mil Sementes");
        jButtonImprimePesoMil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonImprimePesoMilActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jButtonImprimePesoMil, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel10Layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jButtonImprimePesoMil))
        );

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, 350, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(NumPedido, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(33, 33, 33)
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBoxRespTec, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGap(31, 31, 31)
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(precoTotalTudo, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(345, 345, 345)
                        .addComponent(jLabel34, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(recebidopor, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(32, 32, 32)
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jFormattedTextFieldDataPedido, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 211, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 557, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(NovoPedido, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jButtonExcluiPedido)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jButtonSalvaPedido, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addGap(0, 37, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(NumPedido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13)
                    .addComponent(jComboBoxRespTec, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(9, 9, 9)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(precoTotalTudo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel19)
                    .addComponent(jLabel34, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(recebidopor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jFormattedTextFieldDataPedido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jButtonExcluiPedido, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(NovoPedido, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 42, Short.MAX_VALUE)
                    .addComponent(jButtonSalvaPedido, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(153, 153, 153))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void preencheListaBusca(List resultList) {
        Vector tableData = new Vector();
        for (Object o : resultList) {
            Cliente cliente = (Cliente) o;
            String nome = cliente.getNomeCliente();
            if (nome == null) { //pessoa jurica
                nome = cliente.getRazaoSocialCliente();
            }
            tableData.add(nome);
            System.out.println(nome);
        }
        if (tableData.size() == 0) {
            tableData.add("Nenhuma ocorrência");
        }
        jListClientes.setListData(tableData);
    }

    private void preencheListaPedidos(List resultList) {
        Vector tableData = new Vector();
        for (Object o : resultList) {
            PedidoServico ps = (PedidoServico) o;
            String pedido = ps.getIdPedidoServico();
            tableData.add(pedido);
        }
        if (tableData.size() == 0) {
            tableData.add("Nenhuma ocorrência");
        }
        jListPedidos.setListData(tableData);
    }

    private void adicionarRequisitoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_adicionarRequisitoActionPerformed

        String analisesSolicitadas = "";
        if (AnalisePz.isSelected()) {
            analisesSolicitadas += "PZ ";
        }
        if (AnaliseG.isSelected()) {
            analisesSolicitadas += "G ";
        }
        if (AnaliseGa.isSelected()) {
            analisesSolicitadas += "G.A ";
        }
        if (AnaliseEa.isSelected()) {
            analisesSolicitadas += "E.A. ";
        }
        if (AnalisePms.isSelected()) {
            analisesSolicitadas += "PMS ";
        }
        if (AnaliseTz.isSelected()) {
            analisesSolicitadas += "TZ ";
        }
        if (AnaliseOgm.isSelected()) {
            analisesSolicitadas += "OGM ";
        }
        if (AnaliseSi.isSelected()) {
            analisesSolicitadas += "SI ";
        }
        if (AnaliseTs.isSelected()) {
            analisesSolicitadas += "TZ ";
        }
        if (AnaliseUm.isSelected()) {
            analisesSolicitadas += "UM";
        }
        if (qtdAmostra.getText().toString().equals("")) {
            return;
        }
        if (analisesSolicitadas.equals("")) {
            return;
        }
        if (precoUnitario.getText().toString().equals("")) {
            return;
        }
         
        DefaultTableModel model = (DefaultTableModel) tabelaRequisitos.getModel();
        model.addRow(new String[]{
            "Gerada ao salvar", 
            lote.getText().toString(),
            analisesSolicitadas,
            especie.getSelectedItem().toString(),
            peneira.getText().toString(),
            cultivar.getText().toString(),
            sckg.getText().toString(),
            classe.getText().toString(),
            safra.getText().toString(),
            categoria.getText().toString(),
            observacao.getText().toString(),
            basir.getText().toString(),
            substituiVirgula(qtdAmostra.getText().toString()), 
            substituiVirgula(precoUnitario.getText()), 
            substituiVirgula(precoTotal.getText().toString()),
            jFormattedTextFieldDataRecebimento.getText().toString(),
            jFormattedTextFieldDataAmostragem.getText().toString(),
            pesoAmostraSub.getText().toString(),
            tratada.getSelectedItem().toString()});
            
        
        limpaJtextField();
        calculaPrecoTotal();
    }//GEN-LAST:event_adicionarRequisitoActionPerformed

    private void precoUnitarioKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_precoUnitarioKeyReleased
        String precoTexto = precoUnitario.getText();
        precoTexto = precoTexto.replace(",", ".");
        float precoU = Float.valueOf(precoTexto);
        if (Integer.valueOf(qtdAmostra.getText()) > 0 && precoU > 0) {
            float quantidade = Float.parseFloat(qtdAmostra.getText());
            float precoT = precoU * quantidade;
            String precoTotalStr = Float.toString(precoT);
            precoTotalStr = precoTotalStr.replace(".", ",");
            precoTotal.setText(precoTotalStr);
        }
    }//GEN-LAST:event_precoUnitarioKeyReleased

    private void precoTotalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_precoTotalActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_precoTotalActionPerformed

    private void removerRequisitosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removerRequisitosActionPerformed
        DefaultTableModel model = (DefaultTableModel) tabelaRequisitos.getModel();
        if (tabelaRequisitos.getSelectedRow() != -1) {
            model.removeRow(tabelaRequisitos.getSelectedRow());
            calculaPrecoTotal();
        } else {
            JOptionPane.showMessageDialog(null, "Selecione um Requisito!", "Atenção", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_removerRequisitosActionPerformed

    public void calculaPrecoTotal() {
        DefaultTableModel model = (DefaultTableModel) tabelaRequisitos.getModel();
        float total = 0;
        for (int i = 0; i < model.getRowCount(); i++) {
            String precoTexto = (String) model.getValueAt(i, 14);
            precoTexto = precoTexto.replace(",", ".");
            float preco = Float.valueOf(precoTexto);
            total += preco;
        }
        String precoTotalStr = Float.toString(total);
        precoTotalStr = precoTotalStr.replace(".", ",");
        precoTotalTudo.setText(precoTotalStr);
    }

    public void alteraCursor(int tipo) {
        if (tipo == 1) {
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        }
        if (tipo == 0) {
            setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        }
    }

    public void limpaComponentes() {
        jFormattedTextFieldRG.setText("");
        jFormattedTextFieldCpf.setText("");
        jFormattedTextFieldCnpj.setText("");
        jTextFieldNome.setText("");
        jFormattedTextFieldRG.setText("");
        jFormattedTextFieldInscricaoEstadual.setText("");
        jTextFieldRazaoSocial.setText("");
        jComboBoxRespTec.removeAllItems();
        jFormattedTextFieldRenasem.setText("");
//        jListRespTec.setListData(new Vector());
//        jListRespTec.clearSelection();
    }

    public void limpaTabelaEComponentesAposSalvar() {
        limpaJtextField();
        precoTotal.setText("");
        precoTotalTudo.setText("");
        jFormattedTextFieldDataPedido.setText("");
        qtdAmostra.setEditable(false);
        AnaliseEa.setEnabled(false);
        AnaliseG.setEnabled(false);
        AnaliseGa.setEnabled(false);
        AnaliseOgm.setEnabled(false);
        AnalisePms.setEnabled(false);
        AnalisePz.setEnabled(false);
        AnaliseSi.setEnabled(false);
        AnaliseTs.setEnabled(false);
        AnaliseTz.setEnabled(false);
        AnaliseUm.setEnabled(false);
        precoUnitario.setEnabled(false);
        jFormattedTextFieldDataPedido.setEnabled(false);
        adicionarRequisito.setEnabled(false);
        removerRequisitos.setEnabled(false);
        jButtonSalvaPedido.setEnabled(false);
        
         lote.setEditable(false);
        peneira.setEditable(false);
        cultivar.setEditable(false);
        sckg.setEditable(false);
        classe.setEditable(false);
        safra.setEditable(false);
        categoria.setEditable(false);
        basir.setEditable(false);
        observacao.setEditable(false);
        
        DefaultTableModel model = (DefaultTableModel) tabelaRequisitos.getModel();
        for (int i = model.getRowCount() - 1; i >= 0; i--) {
            model.removeRow(i);
        }
    }

    private String getIdDisponivel() {
        
           Calendar calendar = Calendar.getInstance();
        boolean achou = false;
        int quantidade = Consultas.getCount("select count(*) from PedidoServico ");
        int ano = calendar.get(Calendar.YEAR);
        String id = Integer.toString(ano) + "/";
        String sequencia = Integer.toString(quantidade + 1);
        String zeros = "";
        int tamanhho = sequencia.length();
        if (tamanhho < 6) {
            int qntdZeros = 6 - tamanhho;
            for (int i = 0; i < qntdZeros; i++) {
                zeros += "0";
            }
        }
        String novoID = id + zeros + sequencia;
        while (!achou) {
            int existeEsseId = Consultas.getCount("select count(idPedidoServico) from PedidoServico where idPedidoServico = '" + novoID + "'");
            if (existeEsseId == 0) {
                return novoID;
            }
            quantidade++;
            sequencia = Integer.toString(quantidade);
            zeros = "";
            tamanhho = sequencia.length();
            if (tamanhho < 6) {
                int qntdZeros = 6 - tamanhho;
                for (int i = 0; i < qntdZeros; i++) {
                    zeros += "0";
                }
            }
            novoID = id + zeros + sequencia;
        }
        return null;      
    }

    private String getIdAnaliseDisponivel() {
        Calendar calendar = Calendar.getInstance();
        boolean achou = false;
        int quantidade = Consultas.getCount("select count(*) from Analise ");
        int ano = calendar.get(Calendar.YEAR);
        String id = Integer.toString(ano) + "/";
        String sequencia = Integer.toString(quantidade + 1);
        String zeros = "";
        int tamanhho = sequencia.length();
        if (tamanhho < 6) {
            int qntdZeros = 6 - tamanhho;
            for (int i = 0; i < qntdZeros; i++) {
                zeros += "0";
            }
        }
        String novoID = id + zeros + sequencia;
        while (!achou) {
            int existeEsseId = Consultas.getCount("select count(idAnalise) from Analise where idAnalise = '" + novoID + "'");
            if (existeEsseId == 0) {
                return novoID;
            }
            quantidade++;
            sequencia = Integer.toString(quantidade);
            zeros = "";
            tamanhho = sequencia.length();
            if (tamanhho < 6) {
                int qntdZeros = 6 - tamanhho;
                for (int i = 0; i < qntdZeros; i++) {
                    zeros += "0";
                }
            }
            novoID = id + zeros + sequencia;
        }
        return null;
    }

    public void limpaJtextField() {
        qtdAmostra.setText("");
        precoUnitario.setText("");
        precoTotal.setText("");
        lote.setText("");
        peneira.setText("");
        cultivar.setText("");
        sckg.setText("");
        classe.setText("");
        safra.setText("");
        categoria.setText("");
        basir.setText("");
        observacao.setText("");
        AnaliseEa.setSelected(false);
        AnaliseG.setSelected(false);
        AnaliseGa.setSelected(false);
        AnaliseOgm.setSelected(false);
        AnalisePms.setSelected(false);
        AnalisePz.setSelected(false);
        AnaliseSi.setSelected(false);
        AnaliseTs.setSelected(false);
        AnaliseTz.setSelected(false);
        AnaliseUm.setSelected(false);
        jFormattedTextFieldDataRecebimento.setText("");
        jFormattedTextFieldDataAmostragem.setText("");
        pesoAmostraSub.setText("");
            
    }

    private void qtdAmostraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_qtdAmostraActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_qtdAmostraActionPerformed

    private void NumPedidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NumPedidoActionPerformed
   }//GEN-LAST:event_NumPedidoActionPerformed

    private void jButtonExcluiPedidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExcluiPedidoActionPerformed

        int confirmacao = JOptionPane.showConfirmDialog(null, "Ao excluir um Pedido de Serviço, suas analises também serão excluídas.\nConfirma a exclusão?", "Excluir", JOptionPane.YES_NO_OPTION);
        if (confirmacao == 1) {
            return;
        }

        alteraCursor(1);
        String idPedido = NumPedido.getText().toString();
        boolean erro = false;
        String sql = "from Analise where pedidoServico='" + idPedido + "'";
        for (Object o : Consultas.getListObjetos(sql)) {
            Analise a = (Analise) o;
            if (!Consultas.removeDoBanco(a)) {
                erro = true;
            }
        }
        sql = "from PedidoServico where idPedidoServico='" + idPedido + "'";
        PedidoServico pedido = (PedidoServico) Consultas.getUmaLinha(sql);
        if (!erro && Consultas.removeDoBanco(pedido)) {
            limpaComponentes();
            mensagem("Pedido de serviço excluído com sucesso!", SUCESSO);
            jListClientesValueChanged(null);
            alteraCursor(0);
        } else {
            alteraCursor(0);
            mensagem("Erro ao excluir pedido de serviço!", ERRO);
        }
    }//GEN-LAST:event_jButtonExcluiPedidoActionPerformed

    private void jButtonSalvaPedidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSalvaPedidoActionPerformed

        if (jListClientes.getSelectedValue() == null) {
            String mensagem = "Selecione um Cliente";
            mensagem(mensagem, ERRO);
            return;
        }
        if (jListClientes.getSelectedValue().equals("Nenhuma ocorrência")) {
            String mensagem = "Selecione um Cliente";
            mensagem(mensagem, ERRO);
            return;
        }
        if (jComboBoxRespTec.getSelectedItem().toString().equals("Selecione")) {
            String mensagem = "Selecione um responsável Tecnico";
            mensagem(mensagem, ERRO);
            return;
        }
        if (jFormattedTextFieldDataPedido.getText().equals("  /  /    ")) {
            String mensagem = "Preencha a data do pedido";
            mensagem(mensagem, ERRO);
            return;
        }
        if (tabelaRequisitos.getModel().getRowCount() == 0) {
            String mensagem = "Nenhuma análise adicionada";
            mensagem(mensagem, ERRO);
            return;
        }


        alteraCursor(1);
        String idPedido = idPedidoSelecionado;
        if (idPedidoSelecionado.equals("999999")) {//novo Pedido
            idPedido = getIdDisponivel();
        }

        PedidoServico pedido = new PedidoServico();
        Cliente cliente;
        if (jRadioButtonPessoaFisica.isSelected()) {
            cliente = (Cliente) Consultas.getUmaLinha("from Cliente where cpfCliente ='" + jFormattedTextFieldCpf.getText() + "'");
        } else {
            cliente = (Cliente) Consultas.getUmaLinha("from Cliente where cnpjCliente ='" + jFormattedTextFieldCnpj.getText() + "'");
        }
        pedido.setIdPedidoServico(idPedido);
        pedido.setCliente(cliente);
        ResponsavelTecnico responsavel = (ResponsavelTecnico) Consultas.getUmaLinha("from ResponsavelTecnico where nomeRespTec ='" + jComboBoxRespTec.getSelectedItem().toString() + "'");
        pedido.setResponsavelTecnico(responsavel);
        pedido.setDataPedidoServico(jFormattedTextFieldDataPedido.getText());
        pedido.setFuncionarioRecebimento(recebidopor.getText());

        if (Consultas.salvaNoBanco(pedido)) {

            idPedidoSelecionado = idPedido;
            DefaultTableModel model = (DefaultTableModel) tabelaRequisitos.getModel();
            for (int i = 0; i < model.getRowCount(); i++) {
                String idAnalise = model.getValueAt(i, 0).toString();
                if (idAnalise.equals("Gerada ao salvar")) {
                    idAnalise = getIdAnaliseDisponivel();
                }
                       
                Analise analise = new Analise(idAnalise, pedido);
                System.out.println(model.getValueAt(i, 1).toString());
                analise.setLote(model.getValueAt(i, 1).toString());
                analise.setTipoAnalise(model.getValueAt(i, 2).toString());
                analise.setEspecie(model.getValueAt(i, 3).toString());
                analise.setPeneira(model.getValueAt(i, 4).toString());
                analise.setCultivar(model.getValueAt(i, 5).toString());
                analise.setSckg(model.getValueAt(i, 6).toString());
                analise.setClasse(model.getValueAt(i, 7).toString());
                analise.setSafra(model.getValueAt(i, 8).toString());
                analise.setCategoria(model.getValueAt(i, 9).toString());
                analise.setObservacao(model.getValueAt(i, 10).toString());
                analise.setBasir(model.getValueAt(i, 11).toString());
                analise.setQuantidade(Integer.valueOf(model.getValueAt(i, 12).toString()));
                analise.setPrecoUnitario(Double.valueOf(model.getValueAt(i, 13).toString()));
                analise.setRecebimentoAmostra(model.getValueAt(i, 15).toString());
                analise.setDataAmostragem(model.getValueAt(i, 16).toString());
                analise.setPesoAmostra(model.getValueAt(i, 17).toString());
                analise.setTratada(model.getValueAt(i, 18).toString());
                if (!Consultas.salvaNoBanco(analise)) {
                    mensagem("ERRO ao salvar as analises !", ERRO);
                    return;
                }
            }

            //limpaTabelaEComponentesAposSalvar();
            //limpaComponentes();

            mensagem("Pedido " + idPedido + " salvo com sucesso!", SUCESSO);

            String sql = "from PedidoServico where cliente = " + cliente.getIdCliente();
            preencheListaPedidos(Consultas.getListObjetos(sql));

            //atualiza a tabela de analises           
            DefaultTableModel model2 = (DefaultTableModel) tabelaRequisitos.getModel();
            while (model2.getRowCount() > 0) {
                model2.removeRow(0);
            }
            sql = "from Analise where pedidoServico='" + idPedido + "'";
            DefaultTableModel model3 = (DefaultTableModel) tabelaRequisitos.getModel();
            for (Object o : Consultas.getListObjetos(sql)) {
                Analise a = (Analise) o;
                double total = a.getQuantidade() * a.getPrecoUnitario();
                  model.addRow(new String[]{
                a.getIdAnalise(), 
                a.getLote(),
                a.getTipoAnalise(),
                a.getEspecie(),
                a.getPeneira(),
                a.getCultivar(),
                a.getSckg(),
                a.getClasse(),
                a.getSafra(),
                a.getCategoria(),
                a.getObservacao(),
                a.getBasir(),
                a.getQuantidade().toString(), 
                a.getPrecoUnitario().toString(), 
                Double.toString(total),
                a.getRecebimentoAmostra().toString(),
                a.getDataAmostragem().toString(),
                a.getPesoAmostra().toString(),
                a.getTratada().toString()});
        
                //model3.addRow(new String[]{a.getIdAnalise(), a.getQuantidade().toString(), a.getEspecie(), a.getTipoAnalise(), a.getPrecoUnitario().toString(), Double.toString(total)});
            }

            calculaPrecoTotal();
            alteraCursor(0);
        } else {
            alteraCursor(0);
            String mensagem = "Erro ao salvar cliente!";
            mensagem(mensagem, ERRO);
        }
    }//GEN-LAST:event_jButtonSalvaPedidoActionPerformed

    private void NovoPedidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NovoPedidoActionPerformed
        limpaJtextField();
        qtdAmostra.setEditable(true);
        AnaliseEa.setEnabled(true);
        AnaliseG.setEnabled(true);
        AnaliseGa.setEnabled(true);
        AnaliseOgm.setEnabled(true);
        AnalisePms.setEnabled(true);
        AnalisePz.setEnabled(true);
        AnaliseSi.setEnabled(true);
        AnaliseTs.setEnabled(true);
        AnaliseTz.setEnabled(true);
        AnaliseUm.setEnabled(true);
        precoUnitario.setEnabled(true);
        jFormattedTextFieldDataPedido.setEnabled(true);
        adicionarRequisito.setEnabled(true);
        removerRequisitos.setEnabled(true);
        jButtonSalvaPedido.setEnabled(true);       
        idPedidoSelecionado = "999999";
        idClienteSelecionado = 999999;
        especie.setEnabled(true);
        jComboBoxRespTec.setEnabled(true);
        NumPedido.setText("");
        jComboBoxRespTec.setSelectedItem("Selecione");
        precoTotalTudo.setText("");
        mensagem("Preencha os dados do pedido", INFO);
        jFormattedTextFieldDataPedido.setText("");
        jButtonExcluiPedido.setEnabled(false);
        jListPedidos.clearSelection();        
        
        lote.setEditable(true);
        peneira.setEditable(true);
        cultivar.setEditable(true);
        sckg.setEditable(true);
        classe.setEditable(true);
        safra.setEditable(true);
        categoria.setEditable(true);
        basir.setEditable(true);
        observacao.setEditable(true);
        
        Funcionario f = (Funcionario) Consultas.getUmaLinha("from Funcionario where usuario = '" + TelaLogin.USUARIO_LOGADO + "'");
        recebidopor.setText(f.getNomeFuncionario());
 
        DefaultTableModel model = (DefaultTableModel) tabelaRequisitos.getModel();
        while (model.getRowCount() > 0) {
            model.removeRow(0);
        }
    }//GEN-LAST:event_NovoPedidoActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        alteraCursor(1);
        String sql = "from Cliente where upper(nomeCliente) like upper('%" + jTextFieldBuscaCliente.getText() + "%') OR upper(razaoSocialCliente) like upper('%" + jTextFieldBuscaCliente.getText() + "%')";
        preencheListaBusca(Consultas.getListObjetos(sql));
        alteraCursor(0);
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jListClientesValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListClientesValueChanged
//        limpaJtextField();
//        qtdAmostra.setEditable(false);
//        AnaliseEa.setEnabled(false);
//        AnaliseG.setEnabled(false);
//        AnaliseGa.setEnabled(false);
//        AnaliseOgm.setEnabled(false);
//        AnalisePms.setEnabled(false);
//        AnalisePz.setEnabled(false);
//        AnaliseSi.setEnabled(false);
//        AnaliseTs.setEnabled(false);
//        AnaliseTz.setEnabled(false);
//        AnaliseUm.setEnabled(false);
//        precoUnitario.setEnabled(false);
//        jFormattedTextFieldDataPedido.setEnabled(false);
//        adicionarRequisito.setEnabled(false);
//        removerRequisitos.setEnabled(false);
//        jButtonSalvaPedido.setEnabled(false);
//        idPedidoSelecionado = "999999";
//        idClienteSelecionado = 999999;
//        especie.setEnabled(false);
//        jComboBoxRespTec.setEnabled(false);
//        NumPedido.setText("");
//        jButtonExcluiPedido.setEnabled(false);
//        
//         lote.setEditable(false);
//        peneira.setEditable(false);
//        cultivar.setEditable(false);
//        sckg.setEditable(false);
//        classe.setEditable(false);
//        safra.setEditable(false);
//        categoria.setEditable(false);
//        basir.setEditable(false);
//        observacao.setEditable(false);
//
//        DefaultTableModel model = (DefaultTableModel) tabelaRequisitos.getModel();
//        while (model.getRowCount() > 0) {
//            model.removeRow(0);
//        }

        jFormattedTextFieldDataPedido.setText("");

        if (jListClientes.getSelectedValue() == null) {
            return;
        }
        if (jListClientes.getSelectedValue().equals("Nenhuma ocorrência")) {
            return;
        }
        limpaComponentes();
        System.out.println("Selecionado=" + jListClientes.getSelectedValue());
        String sql = "from Cliente where nomeCliente='" + jListClientes.getSelectedValue().toString() + "' OR razaoSocialCliente='" + jListClientes.getSelectedValue().toString() + "'";
        List resultList = Consultas.getListObjetos(sql);
        Cliente cliente;
        PedidoServico pedidoServico;
        for (Object o : resultList) {
            cliente = (Cliente) o;
            idClienteSelecionado = cliente.getIdCliente();
            if (cliente.getPessoaCliente() == 0) { //pessoa fisica
                jRadioButtonPessoaFisica.setSelected(true);
                jRadioButtonPessoaJuridica.setSelected(false);
                jTextFieldNome.setText(cliente.getNomeCliente());
                jFormattedTextFieldCpf.setText(cliente.getCpfCliente());
                jFormattedTextFieldRG.setText(cliente.getRgCliente());
            } else { //pessoa juridica
                jRadioButtonPessoaJuridica.setSelected(true);
                jRadioButtonPessoaFisica.setSelected(false);
                jFormattedTextFieldCnpj.setText(cliente.getCnpjCliente());
                jFormattedTextFieldInscricaoEstadual.setText(cliente.getInscricaoEstadualCliente());
                jTextFieldRazaoSocial.setText(cliente.getRazaoSocialCliente());
            }
            jFormattedTextFieldRenasem.setText(cliente.getRenasemCliente());
            Vector tableData = new Vector();
            for (Object c : cliente.getResponsavelTecnicos()) {
                ResponsavelTecnico rt = (ResponsavelTecnico) c;
                String nome = rt.getNomeRespTec();
                jComboBoxRespTec.addItem(nome);
                System.out.println(nome);
            }
            if (resultList.size() == 0) {
                jComboBoxRespTec.addItem("Não existe Responsável Técnico cadastrado");
            } else {
                jComboBoxRespTec.addItem("Selecione");
            }
            sql = "from PedidoServico where cliente = " + cliente.getIdCliente();
            preencheListaPedidos(Consultas.getListObjetos(sql));

            jComboBoxRespTec.setSelectedItem("Selecione");
        }
    }//GEN-LAST:event_jListClientesValueChanged

    private void jTextFieldRazaoSocialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldRazaoSocialActionPerformed
   }//GEN-LAST:event_jTextFieldRazaoSocialActionPerformed

    private void jFormattedTextFieldCpfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFormattedTextFieldCpfActionPerformed
   }//GEN-LAST:event_jFormattedTextFieldCpfActionPerformed

    private void jButtonVisualizaPedidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonVisualizaPedidoActionPerformed

        if (jListClientes.getSelectedValue() == null) {
            return;
        }
        String numeroPedido = jListClientes.getSelectedValue().toString();
        if (numeroPedido.equals("Nenhuma ocorrência")) {
            return;
        }

        DefaultTableModel modell = (DefaultTableModel) tabelaRequisitos.getModel();
        while (modell.getRowCount() > 0) {
            modell.removeRow(0);
        }

        AnaliseEa.setEnabled(true);
        AnaliseG.setEnabled(true);
        AnaliseGa.setEnabled(true);
        AnaliseOgm.setEnabled(true);
        AnalisePms.setEnabled(true);
        AnalisePz.setEnabled(true);
        AnaliseSi.setEnabled(true);
        AnaliseTs.setEnabled(true);
        AnaliseTz.setEnabled(true);
        AnaliseUm.setEnabled(true);
        precoUnitario.setEnabled(true);
        jFormattedTextFieldDataPedido.setEnabled(true);
        adicionarRequisito.setEnabled(true);
        removerRequisitos.setEnabled(true);
        jButtonSalvaPedido.setEnabled(true);
        especie.setEnabled(true);
        jComboBoxRespTec.setEnabled(true);
        jFormattedTextFieldDataPedido.setEnabled(true);
        qtdAmostra.setEditable(true);
        jButtonExcluiPedido.setEnabled(true);
        jButtonImprimePedido.setEnabled(true);
        jButtonImprimePedido2.setEnabled(true);
        jFormattedTextFieldDataAmostragem.setEnabled(true);
        jFormattedTextFieldDataRecebimento.setEnabled(true);
        tratada.setEnabled(true);
        pesoAmostraSub.setEditable(true);
        
         lote.setEditable(true);
        peneira.setEditable(true);
        cultivar.setEditable(true);
        sckg.setEditable(true);
        classe.setEditable(true);
        safra.setEditable(true);
        categoria.setEditable(true);
        basir.setEditable(true);
        observacao.setEditable(true);
        

        String sql = "from PedidoServico where idPedidoServico='" + jListPedidos.getSelectedValue().toString() + "'";
        PedidoServico pedidoServico = (PedidoServico) Consultas.getUmaLinha(sql);

        recebidopor.setText(pedidoServico.getFuncionarioRecebimento());
        NumPedido.setText(pedidoServico.getIdPedidoServico());
        jFormattedTextFieldDataPedido.setText(pedidoServico.getDataPedidoServico());
        jComboBoxRespTec.setSelectedItem(pedidoServico.getResponsavelTecnico().getNomeRespTec().toString());
        mensagem("Pedido " + pedidoServico.getIdPedidoServico(), INFO);
        sql = "from Analise where pedidoServico='" + pedidoServico.getIdPedidoServico() + "'";
        for (Object o : Consultas.getListObjetos(sql)) {
            Analise a = (Analise) o;
            DefaultTableModel model = (DefaultTableModel) tabelaRequisitos.getModel();
            double total = a.getQuantidade() * a.getPrecoUnitario();
            model.addRow(new String[]{
                a.getIdAnalise(), 
                a.getLote(),
                a.getTipoAnalise(),
                a.getEspecie(),
                a.getPeneira(),
                a.getCultivar(),
                a.getSckg(),
                a.getClasse(),
                a.getSafra(),
                a.getCategoria(),
                a.getObservacao(),
                a.getBasir(),
                a.getQuantidade().toString(), 
                a.getPrecoUnitario().toString(),
                Double.toString(total),
                a.getRecebimentoAmostra(),
                a.getDataAmostragem(),
                a.getPesoAmostra(),
                a.getTratada()});
                
        }
        calculaPrecoTotal();
        
         idPedidoSelecionado = jListPedidos.getSelectedValue().toString();
    }//GEN-LAST:event_jButtonVisualizaPedidoActionPerformed

    private void jButtonImprimePedidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonImprimePedidoActionPerformed
        if (jRadioButtonPessoaFisica.isSelected()) {
            String pedido = jListPedidos.getSelectedValue().toString();
            String precoTotalT = precoTotalTudo.getText().toString();
            List dados = new ArrayList();
            String precoTotala = null;
            DefaultTableModel model = (DefaultTableModel) tabelaRequisitos.getModel();
            for (int i = 0; i < model.getRowCount(); i++) {
                precoTotala = model.getValueAt(i, 14).toString();
                
                dados.add( precoTotala );

                
                }
            
            System.out.print(dados);
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            String arquivo = "relatorios/relatorios/FichaPedidoServicoFisica.jasper";
            // InputStream inputStream = getClass().getResourceAsStream("C:/Users/Eduardo/Documents/NetBeansProjects/Softlabs/relatorios/relatorios/FichaPedidoServico.jasper");
            Map parametros = new HashMap();
            parametros.put("id_pedido_servico", pedido);
            parametros.put("preco_total_tudo",precoTotalT);
            // parametros.put("preco_total",dados);
            
            
            

            try {
                JasperReport inputStream = (JasperReport) JRLoader.loadObject(arquivo);
                ReportUtils.openReport("Pedido de Serviço", inputStream, parametros, ConectaBanco.getPostgreConnection());
                setCursor(Cursor.getDefaultCursor());
            } catch (SQLException exc) {
                exc.printStackTrace();
            } catch (JRException exc) {
                exc.printStackTrace();
            }
            jButtonImprimePedido.setEnabled(false);
        } else {
            String pedido = jListPedidos.getSelectedValue().toString();
            String precoTotalT = precoTotalTudo.getText().toString();
            List dados = new ArrayList();
            String precoTotala = null;
            
            DefaultTableModel model = (DefaultTableModel) tabelaRequisitos.getModel();
            for (int i = 0; i < model.getRowCount(); i++) {
                precoTotala = model.getValueAt(i, 14).toString();
                
                dados.add( precoTotala );

                
                }
            
            System.out.print(dados);
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
             System.out.print(pedido);
            String arquivo = "relatorios/relatorios/FichaPedidoServicoJuridica.jasper";
            // InputStream inputStream = getClass().getResourceAsStream("C:/Users/Eduardo/Documents/NetBeansProjects/Softlabs/relatorios/relatorios/FichaPedidoServico.jasper");
            Map parametros = new HashMap();
            parametros.put("id_pedido_servico", pedido);
            parametros.put("preco_total_tudo",precoTotalT);
           //parametros.put("preco_total",dados);

            try {
                JasperReport inputStream = (JasperReport) JRLoader.loadObject(arquivo);
                ReportUtils.openReport("Pedido de Serviço", inputStream, parametros, ConectaBanco.getPostgreConnection());
                setCursor(Cursor.getDefaultCursor());
            } catch (SQLException exc) {
                exc.printStackTrace();
            } catch (JRException exc) {
                exc.printStackTrace();
            }
            jButtonImprimePedido.setEnabled(false);
        }
    }//GEN-LAST:event_jButtonImprimePedidoActionPerformed

    private void jListPedidosValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListPedidosValueChanged
              
       
    }//GEN-LAST:event_jListPedidosValueChanged

    private void recebidoporActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_recebidoporActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_recebidoporActionPerformed

    private void jTextFieldNomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldNomeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldNomeActionPerformed

    private void jButtonImprimePedido1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonImprimePedido1ActionPerformed
            if (jFormattedTextFieldAnolivro.getText().equals("    ")) {
                String mensagem = "Informe o ano para gerar o livro de protocolo";
                mensagem(mensagem, ERRO);
                return;
            }
            else
            {
                String aux = jFormattedTextFieldAnolivro.getText().toString();
                String anoLivro;  
                anoLivro = aux + "/%";
            
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                String arquivo = "relatorios/relatorios/LivroDeProtocolo.jasper";
                // InputStream inputStream = getClass().getResourceAsStream("C:/Users/Eduardo/Documents/NetBeansProjects/Softlabs/relatorios/relatorios/FichaPedidoServico.jasper");
                Map parametros = new HashMap();
                parametros.put("ano_livro", anoLivro);

                try {
                    JasperReport inputStream = (JasperReport) JRLoader.loadObject(arquivo);
                    ReportUtils.openReport("Livro de Protocolo", inputStream, parametros, ConectaBanco.getPostgreConnection());
                    setCursor(Cursor.getDefaultCursor());
                } catch (SQLException exc) {
                    exc.printStackTrace();
                } catch (JRException exc) {
                    exc.printStackTrace();
                }
           }
    }//GEN-LAST:event_jButtonImprimePedido1ActionPerformed

    private void jButtonImprimePedido2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonImprimePedido2ActionPerformed
       if (jRadioButtonPessoaFisica.isSelected()) {
            String pedido = jListPedidos.getSelectedValue().toString();
            System.out.print(pedido);
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            String arquivo = "relatorios/relatorios/FichaTermoRecebimentoAmostraFisica.jasper";
            // InputStream inputStream = getClass().getResourceAsStream("C:/Users/Eduardo/Documents/NetBeansProjects/Softlabs/relatorios/relatorios/FichaPedidoServico.jasper");
            Map parametros = new HashMap();
            parametros.put("id_pedido_servico", pedido);

            try {
                JasperReport inputStream = (JasperReport) JRLoader.loadObject(arquivo);
                ReportUtils.openReport("Termo de Recebimento de Amostras no Laboratorio", inputStream, parametros, ConectaBanco.getPostgreConnection());
                setCursor(Cursor.getDefaultCursor());
            } catch (SQLException exc) {
                exc.printStackTrace();
            } catch (JRException exc) {
                exc.printStackTrace();
            }
            jButtonImprimePedido2.setEnabled(false);
        } else {
            String pedido = jListPedidos.getSelectedValue().toString();
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
             System.out.print(pedido);
            String arquivo = "relatorios/relatorios/FichaTermoRecebimentoAmostraJuridica.jasper";
            // InputStream inputStream = getClass().getResourceAsStream("C:/Users/Eduardo/Documents/NetBeansProjects/Softlabs/relatorios/relatorios/FichaPedidoServico.jasper");
            Map parametros = new HashMap();
            parametros.put("id_pedido_servico", pedido);

            try {
                JasperReport inputStream = (JasperReport) JRLoader.loadObject(arquivo);
                ReportUtils.openReport("Termo de Recebimento de Amostras no Laboratorio", inputStream, parametros, ConectaBanco.getPostgreConnection());
                setCursor(Cursor.getDefaultCursor());
            } catch (SQLException exc) {
                exc.printStackTrace();
            } catch (JRException exc) {
                exc.printStackTrace();
            }
            jButtonImprimePedido2.setEnabled(false);
        }
    }//GEN-LAST:event_jButtonImprimePedido2ActionPerformed

    private void jButtonEtiquetaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEtiquetaActionPerformed
            DefaultTableModel model = (DefaultTableModel) tabelaRequisitos.getModel();

            if(tabelaRequisitos.getSelectedRowCount() == 0){
                String mensagem = "Selecione uma análise para gerar a etiqueta";
                mensagem(mensagem, ERRO);
                return;
            } 
            
            else{
                String idAnalise = model.getValueAt(tabelaRequisitos.getSelectedRow(),0).toString();
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                String arquivo = "relatorios/relatorios/Etiqueta.jasper";
                // InputStream inputStream = getClass().getResourceAsStream("C:/Users/Eduardo/Documents/NetBeansProjects/Softlabs/relatorios/relatorios/FichaPedidoServico.jasper");
                Map parametros = new HashMap();
                parametros.put("id_analise", idAnalise);

                try {
                    JasperReport inputStream = (JasperReport) JRLoader.loadObject(arquivo);
                    ReportUtils.openReport("Etiqueta", inputStream, parametros, ConectaBanco.getPostgreConnection());
                    setCursor(Cursor.getDefaultCursor());
                } catch (SQLException exc) {
                    exc.printStackTrace();
                } catch (JRException exc) {
                    exc.printStackTrace();
                }
            }
    }//GEN-LAST:event_jButtonEtiquetaActionPerformed

    private void jButtonFichaAnaliseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonFichaAnaliseActionPerformed
       DefaultTableModel model = (DefaultTableModel) tabelaRequisitos.getModel();

            if(tabelaRequisitos.getSelectedRowCount() == 0){
                String mensagem = "Selecione uma análise para gerar a ficha";
                mensagem(mensagem, ERRO);
                return;
            }
           
            else{
                String idAnalise = model.getValueAt(tabelaRequisitos.getSelectedRow(),0).toString();
                String especie = model.getValueAt(tabelaRequisitos.getSelectedRow(),3).toString().toLowerCase();
                String tipo = jComboBoxTipo.getSelectedItem().toString();
                if(especie.equals("milho")){
                    String arquivo = "relatorios/relatorios/FichaAnaliseMilho.jasper";
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                
                // InputStream inputStream = getClass().getResourceAsStream("C:/Users/Eduardo/Documents/NetBeansProjects/Softlabs/relatorios/relatorios/FichaPedidoServico.jasper");
                Map parametros = new HashMap();
                parametros.put("id_analise", idAnalise);
                parametros.put("tipo",tipo);

                try {
                    JasperReport inputStream = (JasperReport) JRLoader.loadObject(arquivo);
                    ReportUtils.openReport("Ficha Análise de Sementes", inputStream, parametros, ConectaBanco.getPostgreConnection());
                    setCursor(Cursor.getDefaultCursor());
                } catch (SQLException exc) {
                    exc.printStackTrace();
                } catch (JRException exc) {
                    exc.printStackTrace();
                }
                }
                if(especie.equals("aveia branca")){
                    String arquivo = "relatorios/relatorios/FichaAnaliseAveiaBranca.jasper";
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                
                // InputStream inputStream = getClass().getResourceAsStream("C:/Users/Eduardo/Documents/NetBeansProjects/Softlabs/relatorios/relatorios/FichaPedidoServico.jasper");
                Map parametros = new HashMap();
                parametros.put("id_analise", idAnalise);
                parametros.put("tipo",tipo);

                try {
                    JasperReport inputStream = (JasperReport) JRLoader.loadObject(arquivo);
                    ReportUtils.openReport("Ficha Análise de Sementes", inputStream, parametros, ConectaBanco.getPostgreConnection());
                    setCursor(Cursor.getDefaultCursor());
                } catch (SQLException exc) {
                    exc.printStackTrace();
                } catch (JRException exc) {
                    exc.printStackTrace();
                }
                }
                if(especie.equals("aveia preta")){
                    String arquivo = "relatorios/relatorios/FichaAnaliseAveiaPreta.jasper";
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                
                // InputStream inputStream = getClass().getResourceAsStream("C:/Users/Eduardo/Documents/NetBeansProjects/Softlabs/relatorios/relatorios/FichaPedidoServico.jasper");
                Map parametros = new HashMap();
                parametros.put("id_analise", idAnalise);
                parametros.put("tipo",tipo);

                try {
                    JasperReport inputStream = (JasperReport) JRLoader.loadObject(arquivo);
                    ReportUtils.openReport("Ficha Análise de Sementes", inputStream, parametros, ConectaBanco.getPostgreConnection());
                    setCursor(Cursor.getDefaultCursor());
                } catch (SQLException exc) {
                    exc.printStackTrace();
                } catch (JRException exc) {
                    exc.printStackTrace();
                }
                }
                if(especie.equals("azevem")){
                    String arquivo = "relatorios/relatorios/FichaAnaliseAzevem.jasper";
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                
                // InputStream inputStream = getClass().getResourceAsStream("C:/Users/Eduardo/Documents/NetBeansProjects/Softlabs/relatorios/relatorios/FichaPedidoServico.jasper");
                Map parametros = new HashMap();
                parametros.put("id_analise", idAnalise);
                parametros.put("tipo",tipo);

                try {
                    JasperReport inputStream = (JasperReport) JRLoader.loadObject(arquivo);
                    ReportUtils.openReport("Ficha Análise de Sementes", inputStream, parametros, ConectaBanco.getPostgreConnection());
                    setCursor(Cursor.getDefaultCursor());
                } catch (SQLException exc) {
                    exc.printStackTrace();
                } catch (JRException exc) {
                    exc.printStackTrace();
                }
                }
                if(especie.equals("feijao")){
                    String arquivo = "relatorios/relatorios/FichaAnaliseFeijao.jasper";
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                
                // InputStream inputStream = getClass().getResourceAsStream("C:/Users/Eduardo/Documents/NetBeansProjects/Softlabs/relatorios/relatorios/FichaPedidoServico.jasper");
                Map parametros = new HashMap();
                parametros.put("Id_Analise", idAnalise);
                parametros.put("tipo",tipo);

                try {
                    JasperReport inputStream = (JasperReport) JRLoader.loadObject(arquivo);
                    ReportUtils.openReport("Ficha Análise de Sementes", inputStream, parametros, ConectaBanco.getPostgreConnection());
                    setCursor(Cursor.getDefaultCursor());
                } catch (SQLException exc) {
                    exc.printStackTrace();
                } catch (JRException exc) {
                    exc.printStackTrace();
                }
                }
                if(especie.equals("trigo")){
                    String arquivo = "relatorios/relatorios/FichaAnaliseTrigo.jasper";
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                
                // InputStream inputStream = getClass().getResourceAsStream("C:/Users/Eduardo/Documents/NetBeansProjects/Softlabs/relatorios/relatorios/FichaPedidoServico.jasper");
                Map parametros = new HashMap();
                parametros.put("id_analise", idAnalise);
                parametros.put("tipo",tipo);

                try {
                    JasperReport inputStream = (JasperReport) JRLoader.loadObject(arquivo);
                    ReportUtils.openReport("Ficha Análise de Sementes", inputStream, parametros, ConectaBanco.getPostgreConnection());
                    setCursor(Cursor.getDefaultCursor());
                } catch (SQLException exc) {
                    exc.printStackTrace();
                } catch (JRException exc) {
                    exc.printStackTrace();
                }
                }
                if(especie.equals("triticale")){
                    String arquivo = "relatorios/relatorios/FichaAnaliseTriticale.jasper";
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                
                // InputStream inputStream = getClass().getResourceAsStream("C:/Users/Eduardo/Documents/NetBeansProjects/Softlabs/relatorios/relatorios/FichaPedidoServico.jasper");
                Map parametros = new HashMap();
                parametros.put("id_analise", idAnalise);
                parametros.put("tipo",tipo);

                try {
                    JasperReport inputStream = (JasperReport) JRLoader.loadObject(arquivo);
                    ReportUtils.openReport("Ficha Análise de Sementes", inputStream, parametros, ConectaBanco.getPostgreConnection());
                    setCursor(Cursor.getDefaultCursor());
                } catch (SQLException exc) {
                    exc.printStackTrace();
                } catch (JRException exc) {
                    exc.printStackTrace();
                }
                }
                if(especie.equals("soja")){
                    String arquivo = "relatorios/relatorios/FichaAnaliseSoja.jasper";
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                
                // InputStream inputStream = getClass().getResourceAsStream("C:/Users/Eduardo/Documents/NetBeansProjects/Softlabs/relatorios/relatorios/FichaPedidoServico.jasper");
                Map parametros = new HashMap();
                parametros.put("id_analise", idAnalise);
                parametros.put("tipo",tipo);

                try {
                    JasperReport inputStream = (JasperReport) JRLoader.loadObject(arquivo);
                    ReportUtils.openReport("Ficha Análise de Sementes", inputStream, parametros, ConectaBanco.getPostgreConnection());
                    setCursor(Cursor.getDefaultCursor());
                } catch (SQLException exc) {
                    exc.printStackTrace();
                } catch (JRException exc) {
                    exc.printStackTrace();
                }
                }  
            }

    }//GEN-LAST:event_jButtonFichaAnaliseActionPerformed

    private void jButtonFichaSanidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonFichaSanidadeActionPerformed
        DefaultTableModel model = (DefaultTableModel) tabelaRequisitos.getModel();

            if(tabelaRequisitos.getSelectedRowCount() == 0){
                String mensagem = "Selecione uma análise para gerar a ficha";
                mensagem(mensagem, ERRO);
                return;
            }
           
            else{
                String idAnalise = model.getValueAt(tabelaRequisitos.getSelectedRow(),0).toString();
                String especiee = model.getValueAt(tabelaRequisitos.getSelectedRow(),3).toString().toLowerCase();
                String tipo = jComboBoxTipo.getSelectedItem().toString();
                if(especiee.equals("feijao")){
                    String arquivo = "relatorios/relatorios/FichaAnaliseSanidadeFeijao.jasper";
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                
                // InputStream inputStream = getClass().getResourceAsStream("C:/Users/Eduardo/Documents/NetBeansProjects/Softlabs/relatorios/relatorios/FichaPedidoServico.jasper");
                Map parametros = new HashMap();
                parametros.put("IdAnalise", idAnalise);
                parametros.put("tipo",tipo);

                try {
                    JasperReport inputStream = (JasperReport) JRLoader.loadObject(arquivo);
                    ReportUtils.openReport("Ficha Análise Sanidade de Sementes", inputStream, parametros, ConectaBanco.getPostgreConnection());
                    setCursor(Cursor.getDefaultCursor());
                } catch (SQLException exc) {
                    exc.printStackTrace();
                } catch (JRException exc) {
                    exc.printStackTrace();
                }
                }
                if(especiee.equals("milho")){
                    String arquivo = "relatorios/relatorios/FichaAnaliseSanidadeMilho.jasper";
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                
                // InputStream inputStream = getClass().getResourceAsStream("C:/Users/Eduardo/Documents/NetBeansProjects/Softlabs/relatorios/relatorios/FichaPedidoServico.jasper");
                Map parametros = new HashMap();
                parametros.put("Id_Analise", idAnalise);
                parametros.put("tipo",tipo);

                try {
                    JasperReport inputStream = (JasperReport) JRLoader.loadObject(arquivo);
                    ReportUtils.openReport("Ficha Análise Sanidade de Sementes", inputStream, parametros, ConectaBanco.getPostgreConnection());
                    setCursor(Cursor.getDefaultCursor());
                } catch (SQLException exc) {
                    exc.printStackTrace();
                } catch (JRException exc) {
                    exc.printStackTrace();
                }
                }
                if(especiee.equals("soja")){
                    String arquivo = "relatorios/relatorios/FichaAnaliseSanidadeSoja.jasper";
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                
                // InputStream inputStream = getClass().getResourceAsStream("C:/Users/Eduardo/Documents/NetBeansProjects/Softlabs/relatorios/relatorios/FichaPedidoServico.jasper");
                Map parametros = new HashMap();
                parametros.put("Id_Analise", idAnalise);
                parametros.put("tipo",tipo);

                try {
                    JasperReport inputStream = (JasperReport) JRLoader.loadObject(arquivo);
                    ReportUtils.openReport("Ficha Análise Sanidade de Sementes", inputStream, parametros, ConectaBanco.getPostgreConnection());
                    setCursor(Cursor.getDefaultCursor());
                } catch (SQLException exc) {
                    exc.printStackTrace();
                } catch (JRException exc) {
                    exc.printStackTrace();
                }
                }
                if(especiee.equals("trigo") || especiee.equals("triticale") || especiee.equals("cevada") || especiee.equals("aveia branca") || especiee.equals("aveia preta") ){
                    String arquivo = "relatorios/relatorios/FichaAnaliseSanidadeTrigo.jasper";
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                
                // InputStream inputStream = getClass().getResourceAsStream("C:/Users/Eduardo/Documents/NetBeansProjects/Softlabs/relatorios/relatorios/FichaPedidoServico.jasper");
                Map parametros = new HashMap();
                if(especiee.equals("trigo"))
                {
                    String nomeCientifico = "TRIGO (Triticum aestivum L.)";
                    parametros.put("Id_Analise", idAnalise);
                    parametros.put("tipo",tipo);
                    parametros.put("cientificus_nomis",nomeCientifico);
                }
                if(especiee.equals("triticale"))
                {
                    String nomeCientifico = "TRITICALE (Triticosecale Wittm.)";
                    parametros.put("Id_Analise", idAnalise);
                    parametros.put("tipo",tipo);
                    parametros.put("cientificus_nomis",nomeCientifico);
                }
                if(especiee.equals("cevada"))
                {
                    String nomeCientifico = "CEVADA  Hordeum vulgare L.";
                    parametros.put("Id_Analise", idAnalise);
                    parametros.put("tipo",tipo);
                    parametros.put("cientificus_nomis",nomeCientifico);
                }
                if(especiee.equals("aveia branca"))
                {
                    String nomeCientifico = "AVEIA BRANCA  (Avena sativa L.)";
                    parametros.put("Id_Analise", idAnalise);
                    parametros.put("tipo",tipo);
                    parametros.put("cientificus_nomis",nomeCientifico);
                }
                if(especiee.equals("aveia preta"))
                {
                    String nomeCientifico = "AVEIA PRETA  (Avena strigosa Schreb.)";
                    parametros.put("Id_Analise", idAnalise);
                    parametros.put("tipo",tipo);
                    parametros.put("cientificus_nomis",nomeCientifico);
                }
                try {
                    JasperReport inputStream = (JasperReport) JRLoader.loadObject(arquivo);
                    ReportUtils.openReport("Ficha Análise Sanidade de Sementes", inputStream, parametros, ConectaBanco.getPostgreConnection());
                    setCursor(Cursor.getDefaultCursor());
                } catch (SQLException exc) {
                    exc.printStackTrace();
                } catch (JRException exc) {
                    exc.printStackTrace();
                }
                }
            }
    }//GEN-LAST:event_jButtonFichaSanidadeActionPerformed

    private void jButtonImprimePesoMilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonImprimePesoMilActionPerformed
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                String arquivo = "relatorios/relatorios/PesoMilSementes.jasper";
                // InputStream inputStream = getClass().getResourceAsStream("C:/Users/Eduardo/Documents/NetBeansProjects/Softlabs/relatorios/relatorios/FichaPedidoServico.jasper");
                Map parametros = new HashMap();
                parametros.put("pedido_servico",jListPedidos.getSelectedValue().toString());

                try {
                    JasperReport inputStream = (JasperReport) JRLoader.loadObject(arquivo);
                    ReportUtils.openReport("Peso de Mil Sementes", inputStream, parametros, ConectaBanco.getPostgreConnection());
                    setCursor(Cursor.getDefaultCursor());
                } catch (SQLException exc) {
                    exc.printStackTrace();
                } catch (JRException exc) {
                    exc.printStackTrace();
                }
    }//GEN-LAST:event_jButtonImprimePesoMilActionPerformed

    public void preencheCombos() {

        String sql = "from ResponsavelTecnico";
        List resultList = Consultas.getListObjetos(sql);

        for (Object c : resultList) {
            ResponsavelTecnico rt = (ResponsavelTecnico) c;
            String nome = rt.getNomeRespTec();
            jComboBoxRespTec.addItem(nome);
        }
        if (resultList.size() == 0) {
            jComboBoxRespTec.addItem("Não existe Responsável Técnico cadastrado");
        } else {
            jComboBoxRespTec.addItem("Selecione");
        }
    }

    public boolean verificaErroCampos(int pessoa) {
        boolean erro = false;
        String mensagem = "";
        String campos = "";

        if (pessoa == 0) {
            if (jTextFieldNome.getText().equals("")) {
                erro = true;
                campos += "\n- Nome";
            }
            if (jFormattedTextFieldCpf.getText().equals("   .   .   -  ")) {
                erro = true;
                campos += "\n- CPF";
            }
            if (jFormattedTextFieldRG.getText().equals("  .   .   - ")) {
                erro = true;
                campos += "\n- RG";
            }
        } else {

            if (jFormattedTextFieldCnpj.getText().equals("  .   .   /    -  ")) {
                erro = true;
                campos += "\n- CNPJ";
            }
            if (jTextFieldRazaoSocial.getText().equals("")) {
                erro = true;
                campos += "\n- Razão Social";
            }
        }
        if (erro) {
            mensagem = "Preencha corretamente os seguintes campos:" + campos;
            mensagem(mensagem, ERRO);
        }
        return erro;
    }

    private void mensagem(String msg, int tipo) {
        if (tipo == 0) { //erro
            mensagens.setForeground(Color.RED);
            mensagens.setText(msg);
        } else if (tipo == 1) { //sucesso
            mensagens.setForeground(Color.BLUE);
            mensagens.setText(msg);
        }
        if (tipo == 2) { //info
            mensagens.setForeground(Color.black);
            mensagens.setText(msg);
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JRadioButton AnaliseEa;
    private javax.swing.JRadioButton AnaliseG;
    private javax.swing.JRadioButton AnaliseGa;
    private javax.swing.JRadioButton AnaliseOgm;
    private javax.swing.JRadioButton AnalisePms;
    private javax.swing.JRadioButton AnalisePz;
    private javax.swing.JRadioButton AnaliseSi;
    private javax.swing.JRadioButton AnaliseTs;
    private javax.swing.JRadioButton AnaliseTz;
    private javax.swing.JRadioButton AnaliseUm;
    private javax.swing.JButton NovoPedido;
    private javax.swing.JTextField NumPedido;
    private javax.swing.JButton adicionarRequisito;
    private javax.swing.JTextField basir;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JTextField categoria;
    private javax.swing.JTextField classe;
    private javax.swing.JTextField cultivar;
    private javax.swing.JComboBox especie;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButtonEtiqueta;
    private javax.swing.JButton jButtonExcluiPedido;
    private javax.swing.JButton jButtonFichaAnalise;
    private javax.swing.JButton jButtonFichaSanidade;
    private javax.swing.JButton jButtonImprimePedido;
    private javax.swing.JButton jButtonImprimePedido1;
    private javax.swing.JButton jButtonImprimePedido2;
    private javax.swing.JButton jButtonImprimePesoMil;
    private javax.swing.JButton jButtonSalvaPedido;
    private javax.swing.JButton jButtonVisualizaPedido;
    private javax.swing.JComboBox jComboBoxRespTec;
    private javax.swing.JComboBox jComboBoxTipo;
    private javax.swing.JFormattedTextField jFormattedTextFieldAnolivro;
    private javax.swing.JFormattedTextField jFormattedTextFieldCnpj;
    private javax.swing.JFormattedTextField jFormattedTextFieldCpf;
    private javax.swing.JFormattedTextField jFormattedTextFieldDataAmostragem;
    private javax.swing.JFormattedTextField jFormattedTextFieldDataPedido;
    private javax.swing.JFormattedTextField jFormattedTextFieldDataRecebimento;
    private javax.swing.JFormattedTextField jFormattedTextFieldInscricaoEstadual;
    private javax.swing.JFormattedTextField jFormattedTextFieldRG;
    private javax.swing.JFormattedTextField jFormattedTextFieldRenasem;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JList jListClientes;
    private javax.swing.JList jListPedidos;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JRadioButton jRadioButtonPessoaFisica;
    private javax.swing.JRadioButton jRadioButtonPessoaJuridica;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField jTextFieldBuscaCliente;
    private javax.swing.JTextField jTextFieldNome;
    private javax.swing.JTextField jTextFieldNomeCliente;
    private javax.swing.JTextField jTextFieldRazaoSocial;
    private javax.swing.JTextField lote;
    private javax.swing.JTextArea mensagens;
    private javax.swing.JTextField observacao;
    private javax.swing.JTextField peneira;
    private javax.swing.JTextField pesoAmostraSub;
    private javax.swing.JFormattedTextField precoTotal;
    private javax.swing.JTextField precoTotalTudo;
    private javax.swing.JFormattedTextField precoUnitario;
    private javax.swing.JFormattedTextField qtdAmostra;
    private javax.swing.JFormattedTextField recebidopor;
    private javax.swing.JButton removerRequisitos;
    private javax.swing.JTextField safra;
    private javax.swing.JTextField sckg;
    private javax.swing.JTable tabelaRequisitos;
    private javax.swing.JComboBox tratada;
    // End of variables declaration//GEN-END:variables

    private String substituiVirgula(String numero) {

        return numero.replace(',', '.');



    }
}
